
/*
实例toast
position包括：'top', 'top-start', 'top-end', 'center', 'center-start', 'center-end', 
'bottom', 'bottom-start', or 'bottom-end'
 */
const Toast = Swal.mixin({
    toast: true,
    position: 'top-end',
    showConfirmButton: false,
    timer: 1500,
    timerProgressBar: true,
    didOpen: (toast) => {
        toast.addEventListener('mouseenter', Swal.stopTimer)
        toast.addEventListener('mouseleave', Swal.resumeTimer)
    }
})

/* 注释原生
Toast.fire({
    icon: 'success',
    title: 'Signed in successfully'
})*/

/*const Toast2=Swal.fire({
    position: 'top-end',
    icon: 'success',
    title: '保存成功',
    grow:'fullscreen',
    showConfirmButton: false,
    timer: 1500
})*/

toast={
    success:function(message,position){
        Toast.fire({
            icon:'success',
            position:position,
            title:message,
        })
    },
    error:function(message,position){
        Toast.fire({
            icon:'error',
            position:position,
            title:message,
        })
    },
    warning:function(message,position){
        Toast.fire({
            icon:'warning',
            position:position,
            title:message,
        })
    },
    //删除弹出提示：回调
    showConfirm:function (confirmParams,callback) {

        Swal.fire({
            title: '确定要删除 &nbsp;<span style="color: red;">'+confirmParams+'</span>&nbsp; ? ',
            text:'删除后不可恢复，请确认删除内容！',
            showDenyButton: true,
            confirmButtonText: `确定`,
            confirmButtonColor: '#d33',
            denyButtonText: `取消`,
            denyButtonColor:'#3085d6',
        }).then((result) => {
            /* Read more about isConfirmed, isDenied below */
            if (result.isConfirmed) {

                if(callback){
                    callback();
                }
                Swal.fire('删除 '+confirmParams+' 成功!', '', 'success');
            }
        })


    }
}